
<template>
    <div class="bread">
        <a-breadcrumb :routes="routes">
            <template #separator>
                <icon-right />
            </template>
        </a-breadcrumb>
    </div>
</template>

<script lang="ts" setup>import db from '@/store/localstorage';
import utils from '@/utils/utils';
import { onMounted, ref } from 'vue';
const breadcrumb: Array<any> = [];
const routes = ref();
let leftMenu = db.get('left-menu');
const currentMenu = db.get('current-menu');
onMounted(() => {
    getPath(leftMenu);
    routes.value = breadcrumb;
})

/**
 * 获取当前路径节点信息
 * @param list 
 */

function getPath(list: Array<any>) {
    if (utils.isEmpty(list) || list.length < 1) {
        return;
    }
    list.map((r: any) => {
        if (currentMenu.indexOf(r.menuId.toString()) >= 0) {
            let item = {
                label: r.name,
                path: r.url
            };
            breadcrumb.push(item);
        }
        if (r.menuNum > 0) {
            getPath(r.children);
        }
    })
}
</script>

<style lang="less" scoped>
.bread {
    padding: 20px 0;
}
</style>